<template>
  <div class="page">
    <div class="header">
      <img src="@/assets/images/logo.png" alt="" />
    </div>
    <div class="main">
      <div class="container">
        <div class="container-top">
          <div class="top">
            <div class="title">政策文件</div>
            <div class="oper">
              <el-button
                type="primary"
                class="close"
                icon="iconfont icon-guanbi"
                @click="back"
                >返回</el-button
              >
            </div>
          </div>
          <div class="search">
            <el-tabs v-model="activeName" @tab-click="handleClick">
              <el-tab-pane label="全部" name="first"></el-tab-pane>
              <el-tab-pane label="最近一周" name="second"></el-tab-pane>
              <el-tab-pane label="最近一月" name="third"></el-tab-pane>
              <el-tab-pane label="本年" name="fourth"></el-tab-pane>
            </el-tabs>
          </div>
        </div>
        <ul class="container-list">
          <li v-for="(item, index) in zhengcelist" :key="index">
            <div class="list-main">
              <div class="main-img">
                <img src="@/assets/images/policy.png" alt="" />
              </div>
              <div class="main-text">
                <p class="title">{{ item.title }}</p>
                <p class="info">
                  <i class="iconfont icon-yonghu"></i>
                  <span>管理员</span>
                  <span>{{ item.add_time | formatTime }}</span>
                </p>
              </div>
            </div>
            <div class="list-oper" @click="DetailsPage(item.a_id)">
              <i class="iconfont icon-qianwang"></i>
              <p>查看</p>
            </div>
          </li>
        </ul>
        <div class="block">
          <el-pagination
            background
            @current-change="handleCurrentChange"
            :current-page.sync="currentPage"
            :page-count="total_page"
            :page-size="pageSize"
            layout="prev, pager, next,slot"
            :total="totalAll"
          >
            <el-input v-model="page"></el-input>
            <span @click="jumperPage()">GO</span>
          </el-pagination>
        </div>
      </div>
    </div>
    <div class="copyright">
      <div class="box">
        <div class="box-text">
          <p>
            <span>主办单位：重庆市教育委员会</span>
            <span>技术支持：重庆佰特思科技有限公司、昭信教育集团</span>
          </p>
          <p>
            <span>联系我们</span>
            <span>电话：023-67919893 023-67778602</span>
            <span>邮箱：cqooc@cqooc.com</span>
          </p>
          <p>
            <a href="http://www.cqooc.com/">渝ICP备14007033号-4</a>
            <a href="http://www.cqooc.com/"
              ><img
                src="@/assets/images/gongan.png"
              />渝公网安备：50011202501338号</a
            >
          </p>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import moment from "moment";
import { ArtList } from "@/api/login";
export default {
  name: "ZhengCe",
  data() {
    return {
      // 当前页
      currentPage: 1,
      // 输入页码
      page: 1,
      // 总页数
      total_page: 0,
      // 每页显示个数
      pageSize: 4,
      // 总条数
      totalAll: 0,
      type: "0",
      token: "",
      zhengcelist: [],
      activeName: "first",
    };
  },
  filters: {
    formatTime(time) {
      return moment(time * 1000).format("YYYY-MM-DD");
    },
  },
  methods: {
    handleCurrentChange(val) {
      this.currentPage = val;
      this.queryArticleList();
    },
    handleClick(tab, event) {
      if (tab.name === "first") {
        this.type = "0";
      } else if (tab.name === "second") {
        this.type = "1";
      } else if (tab.name === "third") {
        this.type = "2";
      } else {
        this.type = "3";
      }
      this.queryArticleList();
    },
    queryArticleList() {
      ArtList({
        token: this.token,
        ac_id: 1,
        ispage: "1",
        type: this.type,
        page_no: this.currentPage,
        page_size: this.pageSize,
      }).then((result) => {
        const { data } = result;
        const { list } = data;
        this.zhengcelist = list;
        this.totalAll = data.count - 0;
        this.total_page = Math.ceil(this.totalAll / this.pageSize);
      });
    },
    DetailsPage(aid) {
      this.$router.push({
        path: "/noDetails",
        query: {
          a_id: aid,
        },
      });
    },
    jumperPage() {
      if (this.page > this.total_page) {
        this.page = this.total_page;
        alert("超过总页数");
      }
      this.currentPage = this.page - 0;
    },
    back() {
      this.$router.go(-1);
    },
  },
  mounted() {
    const token = sessionStorage.getItem("token");
    this.token = token;
    this.queryArticleList();
  },
};
</script>
<style lang='scss' scoped>
img {
  width: 100%;
  height: 100%;
}
.page {
  height: 1080px;
}
.header {
  display: flex;
  align-items: center;
  width: 100%;
  height: 110px;
  background-color: #ffffff;
  font-size: 30px;
  letter-spacing: 2px;
  color: #2b3139;
  margin: 0 auto;
  img {
    width: 387px;
    height: 67px;
    margin: 0 30px 0 40px;
  }
  div {
    text-align: left;
    line-height: 40px;
  }
}
.main {
  position: relative;
  height: 90%;
  background: url(../../assets/images/nologinbg.png);
  padding: 30px 0;
  .container {
    width: 1500px;
    height: 100%;
    margin: 0 auto;
    background-color: #fff;
  }
  .container-top {
    padding: 20px 45px 20px;
    border-bottom: solid 1px #e7e9eb;
    .top {
      display: flex;
      justify-content: space-between;
      margin-bottom: 10px;
      .title {
        font-size: 22px;
        font-family: "黑体";
        color: #5673ff;
        margin-right: 60px;
      }
    }
    .search {
      display: flex;
      & > div {
        margin-right: 45px;
      }
    }
    /deep/.el-tabs__header {
      margin: 0 !important;
    }
    /deep/.el-tabs__item {
      height: 35px;
      line-height: 35px;
      font-size: 18px;
      color: #a1a4b5;
    }
    /deep/.el-tabs__nav-wrap::after {
      background-color: transparent;
    }
    /deep/.el-tabs__item.is-active {
      color: #010101;
    }
    /deep/.el-tabs__active-bar {
      background-color: #5673ff;
    }
    /deep/.el-badge__content.is-fixed.is-dot {
      left: 2px;
      top: 5px;
    }
    /deep/.el-form-item {
      margin-bottom: 0;
      font-size: 16px;
    }
    /deep/.el-form-item__content {
      line-height: 0;
    }
    /deep/input::placeholder {
      color: #2b3139;
      font-family: "PingFang";
    }
    /deep/.el-input__suffix {
      top: 50%;
      transform: translateY(-50%);
    }
    /deep/.el-input__inner {
      padding: 6px 15px;
      line-height: 0;
      height: auto;
      font-size: 16px;
      font-family: "PingFang";
    }
    // /deep/.el-button {
    //   padding: 11px 20px;
    //   background-color: #5672ff;
    //   border: none;
    //   font-family: "PingFang";
    //   font-weight: 700;
    // }
    /deep/.el-input__icon {
      height: auto;
    }
    /deep/.el-select .el-input .el-select__caret {
      transform: none;
    }
    /deep/.el-icon-arrow-up:before {
      content: "\e615";
      font-family: "iconfont";
      font-size: 16px;
    }
  }
  .container-list li {
    padding: 33px 45px 20px;
    border-bottom: solid 1px #e7e9eb;
  }
  .container-list {
    li {
      display: flex;
      align-items: center;
      & > span {
        display: inline-block;
        padding: 7px 17px;
        margin-right: 45px;
        color: #fff;
        border-radius: 5px;
        font-size: 16px;
      }
      .purple {
        background: #bcc6fc;
      }
      .list-main {
        display: flex;
        width: 88%;
        .main-img {
          width: 110px;
          height: 60px;
          margin-right: 30px;
        }
        .main-text {
          text-align: left;
          .title {
            width: 830px;
            line-height: 35px;
            margin-bottom: 10px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-weight: 700;
            color: #2b3139;
            font-size: 16px;
          }
          .info {
            font-size: 16px;
            i {
              color: #5673ff;
              margin-right: 10px;
            }
            span {
              color: #9599a4;
              margin-right: 20px;
            }
          }
        }
      }
      .list-oper {
        text-align: center;
        color: #a1a4b5;
        cursor: pointer;
        i {
          font-size: 20px;
        }
        p {
          margin-top: 5px;
          font-size: 12px;
        }
      }
    }
  }
  .block {
    position: absolute;
    bottom: 6%;
    left: 50%;
    transform: translateX(-50%);
    /deep/.el-input {
      width: 30px;
      height: 100%;
    }
    /deep/.el-input__inner {
      height: 25px;
      padding: 0;
      border: solid 1px #f0f1f4;
    }
    /deep/.el-pagination button,
    /deep/.el-pagination span,
    /deep/.el-pager li {
      height: 25px;
      line-height: 25px;
      color: #181b3b;
      font-weight: 700;
    }
    /deep/.el-pagination span {
      cursor: pointer;
    }
    /deep/.el-pagination.is-background .btn-next,
    /deep/.el-pagination.is-background .btn-prev,
    /deep/.el-pagination.is-background .el-pager li {
      background-color: #fff;
      border: solid 1px #f0f1f4;
      margin-right: 8px;
    }
    /deep/.el-pagination.is-background .el-pager li:not(.disabled).active {
      color: #fff;
      background-color: #5272fd;
      border: solid 1px #3957fd;
      font-size: 16px;
    }
    span {
      display: inline-block;
      width: 35px;
      height: 25px;
      line-height: 25px;
      border: solid 1px #f0f1f4;
      margin-left: 8px;
      cursor: pointer;
      border-radius: 2px;
    }
  }
  .close {
    width: 80px;
    height: 30px;
    line-height: 30px;
    padding: 0;
    border: solid 1px #e7e9eb;
    background-color: rgb(255, 255, 255);
    box-shadow: 0px 4px 15.52px 0.48px rgba(73, 100, 245, 0.14);
    color: #242748;
    /deep/i {
      margin-right: 6px;
      vertical-align: bottom;
    }
  }
  /deep/.el-pagination {
    text-align: center;
  }
}
.copyright {
  background-color: #444547;
  width: 100%;
  height: 155px;
  padding: 40px 0;
  .box {
    width: 1200px;
    margin: 0 auto;
    color: #8f8e8e;
    text-align: left;
    display: flex;
    justify-content: space-between;
    font-family: "黑体";
    .box-text {
      h1 {
        margin-bottom: 40px;
        font-size: 30px;
      }
      p {
        line-height: 30px;
        font-size: 14px;
        a {
          display: inline-block;
        }
        span,
        a {
          margin-right: 20px;
          img {
            width: 22px;
            height: 22px;
            margin-right: 5px;
            vertical-align: middle;
          }
        }
      }
    }
    .box-img {
      width: 30%;
      display: flex;
      div {
        margin-left: 30px;
        width: 130px;
        img {
          height: 130px;
        }
        // a{
        //   display: block;
        // }
        p {
          margin-top: 8px;
          line-height: 15px;
          font-size: 14px;
          text-align: center;
        }
      }
    }
  }
}
</style>